class_name HRigidNode
extends RigidBody3D

var _move_vec:Vector3
var jump:bool = false
var offset = 0

var is_on_floor:bool = true
func set_move_vec(p_move_vec):
	_move_vec = p_move_vec

func set_offset(p_offset):
	offset = p_offset



func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
	state.transform.origin.y+=offset
	state.linear_velocity.x = _move_vec.x*2
	state.linear_velocity.z = _move_vec.z*2
	state.apply_force(Vector3.DOWN*9)
	offset =0
	is_on_floor = false
	if not has_node("RayCast3D"):
		return
	var cs = $RayCast3D
	if ! is_instance_valid(cs):
		return
	cs.force_raycast_update()
	var c =$RayCast3D.get_collider()
	if c:
		var p = $RayCast3D.get_collision_point()
		var h = self.global_position.y -p.y
		if h >0.95 and h<1.05:
			is_on_floor = true
		
